package com.rich.dmr.model;

import android.support.annotation.NonNull;

import java.math.BigDecimal;

public class Frequency {
    public Frequency(int channel, int txFrequency, int rxFrequency) {
        super();
        this.channel = channel;
        this.txFrequency = txFrequency;
        this.rxFrequency = rxFrequency;
    }

    public int getChannel() {
        return channel;
    }

    public void setChannel(int channel) {
        this.channel = channel;
    }

    public int getTxFrequency() {
        return txFrequency;
    }

    public void setTxFrequency(int txFrequency) {
        this.txFrequency = txFrequency;
    }

    public int getRxFrequency() {
        return rxFrequency;
    }

    public void setRxFrequency(int rxFrequency) {
        this.rxFrequency = rxFrequency;
    }

    private int channel;
    private int txFrequency;
    private int rxFrequency;

    @NonNull
    @Override
    public String toString() {
        return "ReadFre:" + channel + "/" + div(txFrequency, 1000000) + "/" + div(rxFrequency, 1000000);
    }

    private BigDecimal div(int v1, int v2) {
        BigDecimal b1 = new BigDecimal(Double.toString(v1));
        BigDecimal b2 = new BigDecimal(Double.toString(v2));
        return b1.divide(b2, 4, BigDecimal.ROUND_HALF_UP);
    }
}
